﻿<!DOCTYPE html>
<html>
<head>
	<meta charset="UTF-8">
	<link rel="stylesheet" type="text/css" href="../themes/default/easyui.css">
	<link rel="stylesheet" type="text/css" href="../themes/icon.css">
	<link rel="stylesheet" type="text/css" href="../demo.css">
	<script type="text/javascript" src="../jquery.min.js"></script>
	<script type="text/javascript" src="../jquery.easyui.min.js"></script>
	<script type="text/javascript" src="../locale/easyui-lang-zh_CN.js"></script>
	<script type="text/javascript" src="../jquery.cookie.js"></script>
    <script type="text/javascript" src="../extend.js"></script>
    <script>
        var dataListCache = null;
        var dataCache = null;
		var dataDetailListCache = null;
		var regions = getRegion();
		var salesPoints = getSalesPoint();
		var titles = getTitle();
		var productions = getProduction();
        var appId = GetQueryString("moduleid");
		var rowEditing = -1;
        var fieldEditing = -1;
        var columnsList = [];
        var editing = false;
		var searchArg = {};
		document.onkeydown = keyDown;
        window.onresize=calSize;
		function getColumnVisable(){
            var allColumn = $('#quoteDetailList').datagrid('getColumnFields');
            for(var j=0;j<allColumn.length;j++){
                var col=$('#quoteDetailList').datagrid('getColumnOption',allColumn[j]);
                if(!(col.hidden)&&(col.editor!=undefined)){
                    columnsList.push(allColumn[j]);
        		}
            }
        }
        $(document).ready(function(){
			initBase();
            setData();
            calSize();
			getColumnVisable();
		});
		function initBase(){
			$('#Type').combobox({data:[{AutoId:1,Name:'一般报价'},{AutoId:2,Name:'促销报价'}]});
			$('#SalesPointSelect').combobox({data:salesPoints});
			$('#TitleSelect').combobox({data:titles});
			$('#RegionSelect').combobox({data:regions});
        }
		function pageChanging(pageNumber, pageSize) {
            showMask("查找中");
            $.get('../../api/quote/list', { Args: searchArg, Length: pageSize, Pos: (pageNumber-1) * pageSize }, function (data) {
                if (data.Result == 0) {
                    dataListCache = JSON.parse(data.Data);
                    $("#quoteList").datagrid("loadData", dataListCache);
                    $("#quoteList").datagrid('getPager').pagination({ total: data.Count, pageNumber: pageNumber, onSelectPage: pageChanging });
                } else {
                    $.messager.alert('提示', data.Message, 'error');
                }
				$('#quoteDetailList').datagrid({pagination:true,rownumbers:true,}).datagrid('clientPaging'); 

                hideMask();
            }, 'json');
        }
        function setData() {
            pageChanging(1,10);
        }
        window.onresize=calSize;
        function calSize(){
            var height=window.parent.document.getElementById("mainFrame").clientHeight;
            var width=window.parent.document.getElementById("mainFrame").clientWidth;
            window.parent.document.getElementById(appId).height = height-32;
            $("#quoteList").datagrid('resize',{height:height-76,width:width-15});
            $("#toolbar").panel({width:width-15});
            $("#editToolbar").panel({width:width-15});
            $("#detailEditToolBar").panel({width:width-15});
            
            $("#editZone").panel('resize',{height:height-76,width:width-15});
            $("#editZone").panel('resize',{width:width-15,height:288});
            $("#quoteDetailList").datagrid('resize',{width:width-15,height:height-402});
        }
        
        function initVal(){
			$('#approveIcon').hide();
            $('#AutoId').val(dataCache.AutoId);
            $('#Flag').val(dataCache.Flag);
            $('#Site').val(dataCache.Site);
			$('#State').val(dataCache.State);
            $('#Code').textbox("setValue",dataCache.Code);
            $('#Name').textbox("setValue",dataCache.Name);
			$('#OpenDate').datebox("setValue",dataCache.OpenDate);
			$('#DueDate').datebox("setValue",dataCache.DueDate);
            if(dataCache.Global){
                document.getElementById("Global").checked = true;
            }else{
                document.getElementById("Global").checked = false;
			}
            $('#Type').combobox("setValue",dataCache.Type);
            $('#Note').textbox("setValue",dataCache.Note);
            $('#Lv').numberbox("setValue",dataCache.Lv);
			if(!dataCache.AutoId){
                $('#TitleSelect').combobox("clear");
				$('#RegionSelect').combobox("clear");
				$('#SalesPointSelect').combobox("clear");
            }else{
				$.get("../../api/quote/listsalespoints?quoteId="+dataCache.AutoId,function(data){
					if(data.Result==0){
						var quote_salespoint = JSON.parse(data.Data);
						var _salespoints = new Array();
						for(var i=0;i<quote_salespoint.length;i++){
							_salespoints.push(quote_salespoint[i].SalesPointId);
						}
						$('#SalesPointSelect').combobox("setValues",_salespoints);
					}
				},"json")
				.error(function(){
					$.messager.alert("错误","系统内部错误","error");
				})
				.complete(function() { 
				});
				$.get("../../api/quote/listtitles?quoteId="+dataCache.AutoId,function(data){
					if(data.Result==0){
						var quote_title = JSON.parse(data.Data);
						var _titles = new Array();
						for(var i=0;i<quote_title.length;i++){
							_titles.push(quote_title[i].TitleId);
						}
						$('#TitleSelect').combobox("setValues",_titles);
					}
				},"json")
				.error(function(){
					$.messager.alert("错误","系统内部错误","error");
				})
				.complete(function() { 
				});
				$.get("../../api/quote/listregions?quoteId="+dataCache.AutoId,function(data){
					if(data.Result==0){
						var quote_region = JSON.parse(data.Data);
						var _region = new Array();
						for(var i=0;i<quote_region.length;i++){
							_region.push(quote_region[i].RegionId);
						}
						$('#RegionSelect').combobox("setValues",_region);
					}
				},"json")
				.error(function(){
					$.messager.alert("错误","系统内部错误","error");
				})
				.complete(function() { 
				});
			}
			listDetail(dataCache.AutoId);
			if(dataCache.State==3||dataCache.State==4){
                $('#approveIcon').show();
            }else{
                $('#approveIcon').hide();
            }
        }
        function createNewRecord(){
		
            dataCache = new Object();
            dataCache.Code = getAutoCode('SAM_QUOTE_SET');
			dataCache.OpenDate = new Date().toLocaleDateString();
			dataCache.DueDate = '2049-12-31';
			dataCache.Type = 1;
			dataCache.Lv = 10;
			dataCache.Global = true;
            initVal();
			$('#approveIcon').hide();
            $('#editContent').window('open');
        }
        function editRecord(rowIndex,rowData){
            dataCache = rowData;
            initVal();
            $('#editContent').window('open');
        }
		function submitQuoteRegion(){
            var _quoteregionselect = $('#RegionSelect').combobox("getValues");
            var _region = new Array();
            for(var i =0;i<_quoteregionselect.length;i++){
                _region.push({AutoId:0,Flag:0,RegionId:_quoteregionselect[i],QuoteId:dataCache.AutoId});
            }
            $.post("../../api/quote/setregions",{MasterId:dataCache.AutoId,Data:_region},function(response){
                if(response.Result==0){
                    dataCache.Region = JSON.parse(response.Data);
                }else{
                    $.messager.alert("错误",response.Message,"error");
                }
            })
            .error(function(){
                $.messager.alert("错误","系统内部错误","error");
            })
            .complete(function() { 
            });		
		}
		function submitQuoteTitle(){
            var _quotetitleselect = $('#TitleSelect').combobox("getValues");
            var _title = new Array();
            for(var i =0;i<_quotetitleselect.length;i++){
                _title.push({AutoId:0,Flag:0,TitleId:_quotetitleselect[i],QuoteId:dataCache.AutoId});
            }
            $.post("../../api/quote/settitles",{MasterId:dataCache.AutoId,Data:_title},function(response){
                if(response.Result==0){
                    dataCache.Title = JSON.parse(response.Data);
                }else{
                    $.messager.alert("错误",response.Message,"error");
                }
            })
            .error(function(){
                $.messager.alert("错误","系统内部错误","error");
            })
            .complete(function() { 
            });		
		}
		function submitQuoteSalesPoint(){
            var _quotesalespointselect = $('#SalesPointSelect').combobox("getValues");
            var _salespoint = new Array();
            for(var i =0;i<_quotesalespointselect.length;i++){
                _salespoint.push({AutoId:0,Flag:0,SalesPointId:_quotesalespointselect[i],QuoteId:dataCache.AutoId});
            }
            $.post("../../api/quote/setsalespoints",{MasterId:dataCache.AutoId,Data:_salespoint},function(response){
                if(response.Result==0){
                    dataCache.SalesPoint = JSON.parse(response.Data);
                }else{
                    $.messager.alert("错误",response.Message,"error");
                }
            })
            .error(function(){
                $.messager.alert("错误","系统内部错误","error");
            })
            .complete(function() { 
            });		
		}
        function submitChange(){
            if (dataCache == null) {
                $.messager.alert("错误", "无法获取被编辑的对象", "error");
                return;
            }
			var oldData = JSON.parse(JSON.stringify(dataCache));
			if(document.getElementById("Global").checked){
				if($('#SalesPointSelect').combobox("getValues").length
					+$('#TitleSelect').combobox("getValues").length
					+$('#RegionSelect').combobox("getValues").length>0)
				{
					$.messager.alert("错误", "全局报价不允许单独设置分发的区域、门店或岗位", "error");
					return;
				}
			}
            showMask();
            dataCache.Flag = $("#Flag").val();
			dataCache.State = $("#State").val();
            dataCache.Code=$("#Code").textbox("getValue");
            dataCache.Name=$("#Name").textbox("getValue");
			dataCache.OpenDate=$("#OpenDate").datebox("getValue");
            dataCache.DueDate=$("#DueDate").datebox("getValue");
            dataCache.Note=$("#Note").textbox("getValue");
            dataCache.Type=$("#Type").combobox("getValue");
            dataCache.Lv=$("#Lv").numberbox("getValue");
			dataCache.Global = document.getElementById("Global").checked
            $.post("../../api/quote/set",dataCache,function(response){
                if(response.Result==0){
                    dataCache = JSON.parse(response.Data);
					submitQuoteTitle();
					submitQuoteRegion();
					submitQuoteSalesPoint();
					submitDetail();
                    if(dataCache.Flag!=1){
                        for(var i=0;i<dataListCache.length;i++){
                            if(dataListCache[i].AutoId == dataCache.AutoId){
                                dataListCache.splice(i,1,dataCache);
								console.log('列表第'+i+'项被更新');
                                break;
                            }
                        }
                    }else{
						dataListCache.splice(0,0,dataCache);
						console.log('新项被追加到列表');
					}
                    $('#quoteList').datagrid('loadData', dataListCache); 
                    $.messager.alert("信息","操作成功","info");
                    $('#editContent').window('close');
                }else{
                    $.messager.alert("错误",response.Message,"error");
					dataCache = oldData;
                }
            })
            .error(function(){
                $.messager.alert("错误","系统内部错误","error");
				dataCache = oldData;
            })
            .complete(function() { 
                hideMask();
            });
        }
        function cusStatusFormatter(value,row,index){
            if(value==0){
                return "潜在客户";
            }else if(value==1){
                return "普通客户";
            }
        }
		function productionFormatter(value,row,index){
			return valToName(productions,value);
        }
		function quoteTypeFormatter(value,row,index){
            if(value==1){
                return "一般报价";
            }else if(value==2){
                return "促销报价";
            }
        }
		function boolFormatter(value,row,index){
            if(value){
                return "是";
            }else{
                return "否";
            }
        }
		function loadDataCache(rowIndex,rowData){
            dataCache = rowData;
			switch(dataCache.State){
				case 1:
					$('#btnDelete').linkbutton({disabled:false});
					$('#btnSubmit').linkbutton({disabled:false});
					$('#btnRecall').linkbutton({disabled:true});
					$('#btnApprove').linkbutton({disabled:true});
					$('#btnReject').linkbutton({disabled:true});
					$('#btnRevert').linkbutton({disabled:true});
					$('#approveIcon').hide();
					break;
				case 2:
					$('#btnDelete').linkbutton({disabled:true});
					$('#btnSubmit').linkbutton({disabled:true});
					$('#btnRecall').linkbutton({disabled:false});
					$('#btnApprove').linkbutton({disabled:false});
					$('#btnReject').linkbutton({disabled:false});
					$('#btnRevert').linkbutton({disabled:true});
					$('#approveIcon').hide();
					break;
				case 3:
					$('#btnDelete').linkbutton({disabled:true});
					$('#btnSubmit').linkbutton({disabled:true});
					$('#btnRecall').linkbutton({disabled:true});
					$('#btnApprove').linkbutton({disabled:true});
					$('#btnReject').linkbutton({disabled:true});
					$('#btnRevert').linkbutton({disabled:false});
					$('#approveIcon').show();
					break;					
				case 4:
					$('#btnDelete').linkbutton({disabled:true});
					$('#btnSubmit').linkbutton({disabled:true});
					$('#btnRecall').linkbutton({disabled:true});
					$('#btnApprove').linkbutton({disabled:true});
					$('#btnReject').linkbutton({disabled:true});
					$('#btnRevert').linkbutton({disabled:false});
					$('#approveIcon').show();
					break;
			}
        }
		function addItem(){
			if(editing){
				$('#quoteDetailList').datagrid('endEdit',rowEditing);
				$('#quoteDetailList').datagrid('insertRow',{index:rowEditing+1,row:{AutoId:0,Flag:0}});
            }else{
                $.messager.alert("消息","先按编辑键进入编辑状态","info");
            }
        }
		function removeItem(){
			if(rowEditing!=-1){
				$('#quoteDetailList').datagrid('cancelEdit', rowEditing).datagrid('deleteRow',rowEditing);
			}else{
				$.messager.alert('提示','需要整行选中才能删除');
			}
        }
        function editTable(){
            if(!editing){
                $('#quoteDetailList').datagrid("enableCellEditing"); 
                editing=true;
                $('#detailAdd').linkbutton("enable"); 
                $('#detailDel').linkbutton("enable"); 
                $('#detailSave').linkbutton("enable"); 
                $('#detailCancel').linkbutton("enable"); 
                $('#detailEdit').linkbutton("disable"); 

            }else{
                $.messager.alert("消息","当前正在编辑中","info");
            }
        }
        function setRowIndex(index,row){
            rowEditing = index;
        }
        function endEditTable(){
            $('#quoteDetailList').datagrid('endEdit',rowEditing);
            $('#quoteDetailList').datagrid("disableCellEditing"); 
            rowEditing = -1;
            fieldEditing = -1;
            editing = false;
            $('#detailAdd').linkbutton("disable"); 
            $('#detailDel').linkbutton("disable"); 
            $('#detailSave').linkbutton("disable"); 
            $('#detailCancel').linkbutton("disable"); 
            $('#detailEdit').linkbutton("enable"); 
        }
		function setEditingLocation(index, field){
            if(!editing){
                return;
            }
            var editor = $('#quoteDetailList').datagrid('getEditor', { index: index, field: field });
            if(editor!=null){
                rowEditing=index;
                fieldEditing=field;
            }
        }
        function resetTable(){
			listDetail(dataCache.AutoId);
            endEditTable();
        }
		function listDetail(quoteId){
            if(quoteId==undefined||quoteId==0){
                $('#quoteDetailList').datagrid("loadData",[]);
                return ;
            }
			$('#quoteDetailList').datagrid("loading");
            $.get("../../api/quote/listdetails?quoteid="+quoteId,function(data){
                if(data.Result==0){
                    var detail = JSON.parse(data.Data);
                    $('#quoteDetailList').datagrid("loadData",detail);
                }
            },"json")
            .error(function(){
                $.messager.alert("错误","系统内部错误","error");
            })
            .complete(function() { 
				$('#quoteDetailList').datagrid("loaded");
            });
        }
		function setProduction(index, row){
			if(editing){
                var edProduction = $('#quoteDetailList').datagrid('getEditor', {index:index,field:'ProductionId'});
                if(edProduction!=null){
                    $(edProduction.target).combogrid({data:productions});
                }
            }
		}

        function submitDetail(){
            if(rowEditing!=-1){
                var valid = $('#quoteDetailList').datagrid('validateRow',rowEditing);
                if(!valid){
                    $.messager.alert("错误","错误的数据格式","error");
                    return;
                }
                $('#quoteDetailList').datagrid('endEdit',rowEditing);
                var data = $('#quoteDetailList').datagrid('getAllRows');
                $.post("../../api/quote/setdetails",{MasterId:dataCache.AutoId,Data:data},function(response){
                    if(response.Result==0){
                        dataCache.Modules = JSON.parse(response.Data);
						return true;
                    }else{
                        $.messager.alert("错误",response.Message,"error");
						return false;
                    }
                })
                .error(function(){
                    $.messager.alert("错误","系统内部错误","error");
					return false;
                })
                .complete(function() { 
                    endEditTable();
                });
            }else{
                endEditTable();
				return false;
            }
        }
		function deleteRecord(){
			if (dataCache == null||dataCache.AutoId==0) {
                $.messager.alert("错误", "请先选中要删除的对象", "error");
                return;
            }
			$.messager.confirm('删除提示', '确定删除该记录?', function(r){
				if (r){
					showMask();
					$.get("../../api/quote/removewithdetail?id="+dataCache.AutoId,function(response){
						if(response.Result==0){
							for(var i=0;i<dataListCache.length;i++){
								if(dataListCache[i].AutoId == dataCache.AutoId){
									dataListCache.splice(i,1);
									break;
								}
							}					
							dataCache = null;
							$('#quoteList').datagrid('loadData', dataListCache); 
							$.messager.alert("信息","操作成功","info");
						}else{
							$.messager.alert("错误",response.Message,"error");
						}
					})
					.error(function(){
						$.messager.alert("错误","系统内部错误","error");
					})
					.complete(function() { 
						hideMask();
					});	
				}
			});		
		}
		function submitRecord(){
			showMask();
			$.get("../../api/quote/submit?id="+dataCache.AutoId,function(response){
				if(response.Result==0){
					for(var i=0;i<dataListCache.length;i++){
						if(dataListCache[i].AutoId == dataCache.AutoId){
							dataListCache[i].State = 2;
							break;
						}
					}					
					dataCache = null;
					$('#quoteList').datagrid('loadData', dataListCache); 
					$.messager.alert("信息","操作成功","info");
					}else{
						$.messager.alert("错误",response.Message,"error");
					}
				})
				.error(function(){
					$.messager.alert("错误","系统内部错误","error");
				})
				.complete(function() { 
					hideMask();
				});	
		}
		function recallRecord(){
			showMask();
			$.get("../../api/quote/recall?id="+dataCache.AutoId,function(response){
				if(response.Result==0){
					for(var i=0;i<dataListCache.length;i++){
						if(dataListCache[i].AutoId == dataCache.AutoId){
							dataListCache[i].State = 1;
							break;
						}
					}					
					dataCache = null;
					$('#quoteList').datagrid('loadData', dataListCache); 
					$.messager.alert("信息","操作成功","info");
					}else{
						$.messager.alert("错误",response.Message,"error");
					}
				})
				.error(function(){
					$.messager.alert("错误","系统内部错误","error");
				})
				.complete(function() { 
					hideMask();
				});	
			
		}
		function approveRecord(){
			showMask();
			$.get("../../api/quote/approve?id="+dataCache.AutoId,function(response){
				if(response.Result==0){
					for(var i=0;i<dataListCache.length;i++){
						if(dataListCache[i].AutoId == dataCache.AutoId){
							dataListCache[i].State = 3;
							break;
						}
					}					
					dataCache = null;
					$('#quoteList').datagrid('loadData', dataListCache); 
					$.messager.alert("信息","操作成功","info");
					$('#approveIcon').hide();
				}else{
					$.messager.alert("错误",response.Message,"error");
				}
				})
				.error(function(){
					$.messager.alert("错误","系统内部错误","error");
				})
				.complete(function() { 
					hideMask();
				});	
			
		}
		function revertRecord(){
			showMask();
			$.get("../../api/quote/revert?id="+dataCache.AutoId,function(response){
				if(response.Result==0){
					for(var i=0;i<dataListCache.length;i++){
						if(dataListCache[i].AutoId == dataCache.AutoId){
							dataListCache[i].State = 1;
							break;
						}
					}					
					dataCache = null;
					$('#quoteList').datagrid('loadData', dataListCache); 
					$.messager.alert("信息","操作成功","info");
					$('#approveIcon').hide();
					}else{
						$.messager.alert("错误",response.Message,"error");
					}
				})
				.error(function(){
					$.messager.alert("错误","系统内部错误","error");
				})
				.complete(function() { 
					hideMask();
				});	
			
		}
		function rejectRecord(){
			showMask();
			$.get("../../api/quote/reject?id="+dataCache.AutoId,function(response){
				if(response.Result==0){
					for(var i=0;i<dataListCache.length;i++){
						if(dataListCache[i].AutoId == dataCache.AutoId){
							dataListCache[i].State = 1;
							break;
						}
					}					
					dataCache = null;
					$('#quoteList').datagrid('loadData', dataListCache); 
					$.messager.alert("信息","操作成功","info");
					}else{
						$.messager.alert("错误",response.Message,"error");
					}
				})
				.error(function(){
					$.messager.alert("错误","系统内部错误","error");
				})
				.complete(function() { 
					hideMask();
				});	
		}
		function keyDown(event) {
            if(!editing){
                return;
            }
            var e = event || window.event;
            var keyCode = e.keyCode || e.which;
            switch (keyCode) {
                case 37:
                    hMove(-1);
                    break;
                case 39:
                    hMove(1);
                    break;
            }
        }
        function hMove(direction){
            if(rowEditing==-1){
                return;
            }
            if(fieldEditing==-1){
                fieldEditing = columnsList[0];
            }
            var ed=$('#quoteDetailList').datagrid('getEditor', {index:rowEditing,field:fieldEditing});
            if(!ed){
                return;
            }
            if(direction>=0){
                direction=1;
            }
            else{
                direction=-1;
            }
            var tag = null;
            if($(ed.target).data('textbox')){
                tag = $(ed.target).textbox('textbox')[0];
            }
            var valueLenth=tag.value.length;
            if(tag==null||tag.readOnly||(tag.selectionStart==0 || tag.selectionStart==undefined)&&direction<0
                ||(tag.selectionEnd==valueLenth || tag.selectionEnd==undefined)&&direction>=0){
                for(var i=0;i<columnsList.length;i++){
                    if(fieldEditing==columnsList[i] && (i+direction)>=0 && (i+direction)<columnsList.length){
                        fieldEditing=columnsList[(i+direction)];
                        break;
                    }
                }
                setCellEditable();
            }
            
        }
		function setCellEditable(){
            $('#quoteDetailList').datagrid('validateRow', rowEditing);
            $('#quoteDetailList').datagrid('endEdit', rowEditing);
            $('#quoteDetailList').datagrid('selectRow', rowEditing).datagrid('editCell', {index: rowEditing,field: fieldEditing});
        }
    </script>
</head>
<body onload = "hideMask()">
    <script>showMask('正在载入数据');</script>
	<div id="toolbar" class="easyui-panel" style="padding:1px;">
		<a href="#" id="btnCreate" class="easyui-linkbutton" data-options="onClick:createNewRecord,iconCls:'icon-edit',plain:true">新建</a>
		<a href="#" id="btnDelete" class="easyui-linkbutton" data-options="onClick:deleteRecord, iconCls:'icon-remove',plain:true">删除</a>
        <a href="#" id="btnSearch" class="easyui-linkbutton" data-options="iconCls:'icon-search',plain:true">搜索</a>
		<a href="#" id="btnSubmit" class="easyui-linkbutton" data-options="onClick:submitRecord,iconCls:'icon-redo',plain:true,disabled:true">提审</a>
		<a href="#" id="btnRecall" class="easyui-linkbutton" data-options="onClick:recallRecord,iconCls:'icon-undo',plain:true,disabled:true">撤回</a>
		<a href="#" id="btnApprove" class="easyui-linkbutton" data-options="onClick:approveRecord,iconCls:'icon-ok',plain:true,disabled:true">审核</a>
		<a href="#" id="btnRevert" class="easyui-linkbutton" data-options="onClick:revertRecord,iconCls:'icon-cancel',plain:true,disabled:true">反审</a>
		<a href="#" id="btnReject" class="easyui-linkbutton" data-options="onClick:rejectRecord,iconCls:'icon-clear',plain:true,disabled:true">退回</a>
	</div>
    <div style="margin:2px"></div>
    <table id="quoteList" class="easyui-datagrid"
		data-options="singleSelect:true,method:'get',onClickRow:loadDataCache,onDblClickRow:editRecord,striped:true,">
        <thead>
            <tr>
                <th data-options="field:'AutoId',hidden:true"></th>
                <th data-options="field:'Flag',hidden:true"></th>
                <th data-options="field:'Code',width:140,align:'right'">报价编号</th>
                <th data-options="field:'Name',width:120,align:'right'">报价名称</th>
                <th data-options="field:'OpenDate',width:120,align:'right'">生效日期</th>
                <th data-options="field:'DueDate',width:120,align:'right'">失效日期</th>
                <th data-options="field:'Global',width:120,align:'right',formatter:boolFormatter">全局报价</th>
                <th data-options="field:'Note',width:120,align:'right',hidden:true">备注</th>
                <th data-options="field:'Type',width:120,align:'right',formatter:quoteTypeFormatter">类型</th>
                <th data-options="field:'Lv',width:120,align:'right'">级别</th>
				<th data-options="field:'State',width:100,formatter:stateFormatter">状态</th>
            </tr>
        </thead>
    </table>
    <div id="editContent" class="easyui-window" title="编辑框" data-options="noheader:true,maximized:true,modal:true,closed:true,iconCls:'icon-save',border:false" style="padding:5px 5px 0px 5px">
        <div class="easyui-panel" id="editToolbar" style="padding:1px;width:100%">
            <a href="#" class="easyui-linkbutton" data-options="onClick:submitChange,iconCls:'icon-save',plain:true">保存</a>
            <a href="#" class="easyui-linkbutton" data-options="onClick:initVal,iconCls:'icon-no',plain:true">取消</a>
            <a href="#" class="easyui-linkbutton" data-options="onClick:function(){$('#editContent').window('close');},iconCls:'icon-blank',plain:true">关闭</a>
        </div>
        <div style="margin:2px"></div>
        <div id="editZone" class="easyui-panel" style="padding:4px 4px 0px 4px" >
            <table>
                <tr>
                    <td><input class="easyui-textbox" id="Code"  style="width:300px" data-options="label:'报价代号:',required:true"></td>
                    <td>&nbsp;</td>
                    <td><input class="easyui-textbox" id="Name"  style="width:300px" data-options="label:'报价名称:'"></td>
                </tr>
				<tr>
                    <td><input class="easyui-datebox" id="OpenDate"  style="width:300px" data-options="label:'生效日期:',formatter:dateFormatter,parser:dateParser"></td>
                    <td>&nbsp;</td>
                    <td><input class="easyui-datebox" id="DueDate"  style="width:300px" data-options="label:'失效日期:',formatter:dateFormatter,parser:dateParser"></td>
                </tr>
				<tr>
                    <td><input class="easyui-combobox" id="Type"  style="width:300px" data-options="label:'类型:',valueField:'AutoId',textField:'Name'"></td>
                    <td>&nbsp;</td>
                    <td><input class="easyui-numberbox" id="Lv"  style="width:300px" data-options="label:'级别:'"></td>
                </tr>
				<tr>
                    <td>全局报价<input type="checkbox"  id="Global"/></td>
                    <td>&nbsp;</td>
                    <td></td>
                </tr>
				<tr>
                    <td colspan=3><input class="easyui-textbox" id="Note"  style="width:700px" data-options="label:'备注:'"></td>
                </tr>
				<tr>
                    <td  colspan="3"><input class="easyui-combobox" id="TitleSelect"  style="width:700px" data-options="label:'分发岗位:',multiple:true,valueField: 'AutoId',textField: 'Name',"></td>
                </tr>
                <tr>
                    <td colspan="3"><input class="easyui-combobox" id="SalesPointSelect"  style="width:700px" data-options="label:'分发门店:',multiline:true,multiple:true,valueField: 'AutoId',textField: 'Name',"></td>
                </tr>
				<tr>
                    <td colspan="3"><input class="easyui-combobox" id="RegionSelect"  style="width:700px" data-options="label:'分发区域:',multiline:true,multiple:true,valueField: 'AutoId',textField: 'Name',"></td>
                </tr>
            </table>
			<div id='approveIcon' hidden=true style="z-index:999;position: absolute;top: 50px;right: 50px;width: 216px;height:157px;background: url(../image/approved.png)"></div>
            <div hidden>
                <p id="AutoId"></p>
                <p id="Flag"></p>
                <p id="Site"></p>
				<p id="State"></p>
            </div>
        </div>
		<div style="margin:2px"></div>
                <div class="easyui-panel" id="detailEditToolBar" style="padding:1px;width:100%">
            <a href="#" id="detailEdit" class="easyui-linkbutton" data-options="onClick:editTable,iconCls:'icon-edit',plain:true">开始</a>
            <a href="#" id="detailAdd"  class="easyui-linkbutton" data-options="onClick:addItem,iconCls:'icon-add',plain:true,disabled:true">增行</a>
            <a href="#" id="detailDel"  class="easyui-linkbutton" data-options="onClick:removeItem,iconCls:'icon-remove',plain:true,disabled:true">删行</a>
            <a href="#" id="detailCancel"   class="easyui-linkbutton" data-options="onClick:resetTable,iconCls:'icon-no',plain:true,disabled:true">取消</a>
        </div>
        <div style="margin:2px"></div>
        <table id="quoteDetailList" class="easyui-datagrid" style="width:100%;" data-options="singleSelect:true,method:'get',height:'400',onClickRow:setRowIndex,onClickCell:setEditingLocation">
            <thead>
                <tr>
                    <th data-options="field:'AutoId',hidden:true"></th>
                    <th data-options="field:'Flag',hidden:true"></th>
					<th data-options="field:'State',hidden:true"></th>
                    <th data-options="field:'QuoteId',hidden:true"></th>
                    <th data-options="field:'ProductionId',width:120,align:'right',
						formatter:productionFormatter,
						editor:{
							type:'combogrid',
							options:getComboGridInfo(null,'Name',[[
									{field:'AutoId',title:'ID',width:60},
									{field:'Code',title:'代号',width:100},
									{field:'SearchCode',title:'搜索码',width:100},
									{field:'Name',title:'名称',width:300}
								]],productions)
						}">产品</th>
                    <th data-options="field:'PriceLv0',width:100,align:'right',editor:{type:'numberbox',options:{precision:2}}">价格1</th>
					<th data-options="field:'PriceLv1',width:100,align:'right',editor:{type:'numberbox',options:{precision:2}}">价格2</th>
					<th data-options="field:'PriceLv2',width:100,align:'right',editor:{type:'numberbox',options:{precision:2}}">价格3</th>
					<th data-options="field:'PriceLv3',width:100,align:'right',editor:{type:'numberbox',options:{precision:2}}">价格4</th>
					<th data-options="field:'PriceLv4',width:100,align:'right',editor:{type:'numberbox',options:{precision:2}}">价格5</th>
					<th data-options="field:'PriceLv5',width:100,align:'right',editor:{type:'numberbox',options:{precision:2}}">价格6</th>
                </tr>
            </thead>
        </table>
	</div>
</body>
</html>